//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS MarketplaceEntitlementService service.
///
/// AWS Marketplace Entitlement Service This reference provides descriptions of the AWS Marketplace Entitlement Service API. AWS Marketplace Entitlement Service is used to determine the entitlement of a customer to a given product. An entitlement represents capacity in a product owned by the customer. For example, a customer might own some number of users or seats in an SaaS application or some amount of data capacity in a multi-tenant database.  Getting Entitlement Records     GetEntitlements- Gets the entitlements for a Marketplace product.
public struct MarketplaceEntitlementService: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the MarketplaceEntitlementService client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "AWSMPEntitlementService",
            serviceName: "MarketplaceEntitlementService",
            serviceIdentifier: "entitlement.marketplace",
            signingName: "aws-marketplace",
            serviceProtocol: .json(version: "1.1"),
            apiVersion: "2017-01-11",
            endpoint: endpoint,
            serviceEndpoints: Self.serviceEndpoints,
            variantEndpoints: Self.variantEndpoints,
            errorType: MarketplaceEntitlementServiceErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }


    /// custom endpoints for regions
    static var serviceEndpoints: [String: String] {[
        "cn-northwest-1": "entitlement-marketplace.cn-northwest-1.amazonaws.com.cn"
    ]}


    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.dualstack]: .init(endpoints: [
            "cn-northwest-1": "entitlement-marketplace.cn-northwest-1.api.amazonwebservices.com.cn",
            "us-east-1": "entitlement-marketplace.us-east-1.api.aws"
        ])
    ]}

    // MARK: API Calls

    /// GetEntitlements retrieves entitlement values for a given product. The results can be filtered based on customer identifier, AWS account ID, or product dimensions.   The CustomerIdentifier parameter is on path for deprecation. Use CustomerAWSAccountID instead. These parameters are mutually exclusive. You can't specify both CustomerIdentifier and CustomerAWSAccountID in the same request.
    @Sendable
    @inlinable
    public func getEntitlements(_ input: GetEntitlementsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetEntitlementsResult {
        try await self.client.execute(
            operation: "GetEntitlements", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// GetEntitlements retrieves entitlement values for a given product. The results can be filtered based on customer identifier, AWS account ID, or product dimensions.   The CustomerIdentifier parameter is on path for deprecation. Use CustomerAWSAccountID instead. These parameters are mutually exclusive. You can't specify both CustomerIdentifier and CustomerAWSAccountID in the same request.
    ///
    /// Parameters:
    ///   - filter: Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described as keys mapped to a lists of values. Filtered requests are unioned for each value in the value list, and then intersected for each filter key.  CustomerIdentifier and CustomerAWSAccountID are mutually exclusive. You can't specify both in the same request.
    ///   - maxResults: The maximum number of items to retrieve from the GetEntitlements operation. For pagination, use the NextToken field in subsequent calls to GetEntitlements.
    ///   - nextToken: For paginated calls to GetEntitlements, pass the NextToken from the previous GetEntitlementsResult.
    ///   - productCode: Product code is used to uniquely identify a product in AWS Marketplace. The product code will be provided by AWS Marketplace when the product listing is created.
    ///   - logger: Logger use during operation
    @inlinable
    public func getEntitlements(
        filter: [GetEntitlementFilterName: [String]]? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        productCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetEntitlementsResult {
        let input = GetEntitlementsRequest(
            filter: filter, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            productCode: productCode
        )
        return try await self.getEntitlements(input, logger: logger)
    }
}

extension MarketplaceEntitlementService {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: MarketplaceEntitlementService, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension MarketplaceEntitlementService {
    /// Return PaginatorSequence for operation ``getEntitlements(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func getEntitlementsPaginator(
        _ input: GetEntitlementsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<GetEntitlementsRequest, GetEntitlementsResult> {
        return .init(
            input: input,
            command: self.getEntitlements,
            inputKey: \GetEntitlementsRequest.nextToken,
            outputKey: \GetEntitlementsResult.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``getEntitlements(_:logger:)``.
    ///
    /// - Parameters:
    ///   - filter: Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described as keys mapped to a lists of values. Filtered requests are unioned for each value in the value list, and then intersected for each filter key.  CustomerIdentifier and CustomerAWSAccountID are mutually exclusive. You can't specify both in the same request.
    ///   - maxResults: The maximum number of items to retrieve from the GetEntitlements operation. For pagination, use the NextToken field in subsequent calls to GetEntitlements.
    ///   - productCode: Product code is used to uniquely identify a product in AWS Marketplace. The product code will be provided by AWS Marketplace when the product listing is created.
    ///   - logger: Logger used for logging
    @inlinable
    public func getEntitlementsPaginator(
        filter: [GetEntitlementFilterName: [String]]? = nil,
        maxResults: Int? = nil,
        productCode: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<GetEntitlementsRequest, GetEntitlementsResult> {
        let input = GetEntitlementsRequest(
            filter: filter, 
            maxResults: maxResults, 
            productCode: productCode
        )
        return self.getEntitlementsPaginator(input, logger: logger)
    }
}

extension MarketplaceEntitlementService.GetEntitlementsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> MarketplaceEntitlementService.GetEntitlementsRequest {
        return .init(
            filter: self.filter,
            maxResults: self.maxResults,
            nextToken: token,
            productCode: self.productCode
        )
    }
}
